package cn.itcast.activiti.servlet.processinstance;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RuntimeService;

import cn.itcast.activiti.common.ProcessEngineUtils;

/**
 * 流程实例走一步
 * @author Administrator
 *
 */
@WebServlet("/singleProcessInstance.action")
public class SingleProcessInstanceServlet extends HttpServlet{
	private static final long serialVersionUID = 9112994070018274907L;
	
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	//获取流程定义Id	
	String pdId=request.getParameter("pdId");
	//获取流程实例Id
	String piId=request.getParameter("piId");
	
	/** 获取流程引擎 */
	ProcessEngine processEngine=ProcessEngineUtils.getProcessEngine();
	/** 获取运行时服务 */
	RuntimeService runtimeService=processEngine.getRuntimeService();
	/** 发送信号触发流程实例走一步 */
	runtimeService.signal(piId);
	
	//转发
	response.sendRedirect(request.getContextPath()+"/queryProcessInstanceByPdId.action?pdId="+pdId);
	}

}
